package org.jivesoftware.smackx.packet;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import org.jivesoftware.smack.packet.PacketExtension;

public class HeadersExtension
  implements PacketExtension
{
  public static final String NAMESPACE = "http://jabber.org/protocol/shim";
  private Collection<Header> headers = Collections.EMPTY_LIST;

  public HeadersExtension(Collection<Header> paramCollection)
  {
    if (paramCollection != null)
      this.headers = paramCollection;
  }

  public String getElementName()
  {
    return "headers";
  }

  public Collection<Header> getHeaders()
  {
    return this.headers;
  }

  public String getNamespace()
  {
    return "http://jabber.org/protocol/shim";
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder("<" + getElementName() + " xmlns='" + getNamespace() + "'>");
    Iterator localIterator = this.headers.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        localStringBuilder.append("</" + getElementName() + '>');
        return localStringBuilder.toString();
      }
      localStringBuilder.append(((Header)localIterator.next()).toXML());
    }
  }
}